//public class mysql2 {
//}
//
//
//Enter password: *********
//Welcome to the MySQL monitor.  Commands end with ; or \g.
//Your MySQL connection id is 8
//Server version: 8.0.39 MySQL Community Server - GPL
//
//Copyright (c) 2000, 2024, Oracle and/or its affiliates.
//
//Oracle is a registered trademark of Oracle Corporation and/or its
//affiliates. Other names may be trademarks of their respective
//owners.
//
//        Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
//
//mysql> show databases;
//+--------------------+
//        | Database           |
//        +--------------------+
//        | bit_mall           |
//        | homework           |
//        | information_schema |
//        | java113            |
//        | mysql              |
//        | performance_schema |
//        | sys                |
//        | test               |
//        | test2              |
//        +--------------------+
//        9 rows in set (0.01 sec)
//
//mysql> use java113;
//Database changed
//mysql> show tables;
//+-------------------+
//        | Tables_in_java113 |
//        +-------------------+
//        | class             |
//        | course            |
//        | emp               |
//        | score             |
//        | stu2              |
//        | student           |
//        +-------------------+
//        6 rows in set (0.00 sec)
//
//mysql> select * from student;
//+------------+-------+-----------------+------------------+----------+
//        | student_id | sn    | name            | mail             | class_id |
//        +------------+-------+-----------------+------------------+----------+
//        |          1 | 09982 | 黑旋风李逵      | xuanfeng@qq.com  |        1 |
//        |          2 | 00835 | 菩提老祖        | NULL             |        1 |
//        |          3 | 00391 | 白素贞          | NULL             |        1 |
//        |          4 | 00031 | 许仙            | xuxian@qq.com    |        1 |
//        |          5 | 00054 | 不想毕业        | NULL             |        1 |
//        |          6 | 51234 | 好好说话        | say@qq.com       |        2 |
//        |          7 | 83223 | tellme          | NULL             |        2 |
//        |          8 | 09527 | 老外学中文      | foreigner@qq.com |        2 |
//        +------------+-------+-----------------+------------------+----------+
//        8 rows in set (0.01 sec)
//
//mysql> select * from stu2;
//+------------+--------+-----------------+-----------------+----------+
//        | student_id | sn     | name            | mail            | class_id |
//        +------------+--------+-----------------+-----------------+----------+
//        |          1 | 09982  | 黑旋风李逵      | xuanfeng@qq.com |        1 |
//        |          2 | 000001 | 测 试           | NULL            |        2 |
//        +------------+--------+-----------------+-----------------+----------+
//        2 rows in set (0.00 sec)
//
//mysql> use test;
//Database changed
//mysql> show tables;
//+----------------+
//        | Tables_in_test |
//        +----------------+
//        | class          |
//        | score          |
//        | stu            |
//        | stu2           |
//        +----------------+
//        4 rows in set (0.00 sec)
//
//mysql> select * from score;
//+----+-----------+---------+------+---------+
//        | id | name      | chinese | math | english |
//        +----+-----------+---------+------+---------+
//        |  3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |  4 | 曹孟德    |    70.0 | 30.0 |    67.0 |
//        |  6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |  8 | 孙行者    |    87.5 | 78.0 |    77.0 |
//        +----+-----------+---------+------+---------+
//        4 rows in set (0.01 sec)
//
//mysql> select * from stu;
//+----+--------+----------+
//        | id | name   | class_id |
//        +----+--------+----------+
//        |  1 | 张三   |        1 |
//        |  2 | 李四   |        2 |
//        |  3 | 王五   |        3 |
//        +----+--------+----------+
//        3 rows in set (0.01 sec)
//
//mysql> select * from stu2;
//Empty set (0.00 sec)
//
//mysql> insert into stu2 select * from stu;
//ERROR 3819 (HY000): Check constraint 'stu2_chk_1' is violated.
//mysql> desc stu2
//    -> ;
//            +--------+-------------+------+-----+---------+----------------+
//            | Field  | Type        | Null | Key | Default | Extra          |
//        +--------+-------------+------+-----+---------+----------------+
//        | id     | int         | NO   | PRI | NULL    | auto_increment |
//        | name   | varchar(20) | NO   |     | NULL    |                |
//        | gender | varchar(1)  | NO   |     | NULL    |                |
//        +--------+-------------+------+-----+---------+----------------+
//        3 rows in set (0.00 sec)
//
//mysql> insert into stu2 select (id name) from stu;
//ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'name) from stu' at line 1
//mysql> insert into stu2 select (id, name) from stu;
//ERROR 1241 (21000): Operand should contain 1 column(s)
//mysql> select * from stu2;
//Empty set (0.00 sec)
//
//mysql> desc stu;
//+----------+-------------+------+-----+---------+----------------+
//        | Field    | Type        | Null | Key | Default | Extra          |
//        +----------+-------------+------+-----+---------+----------------+
//        | id       | int         | NO   | PRI | NULL    | auto_increment |
//        | name     | varchar(20) | NO   |     | NULL    |                |
//        | class_id | int         | YES  | MUL | NULL    |                |
//        +----------+-------------+------+-----+---------+----------------+
//        3 rows in set (0.00 sec)
//
//mysql> insert into stu2 (id, name) select (id, name) from stu;
//ERROR 1241 (21000): Operand should contain 1 column(s)
//mysql> select * from stu2;
//Empty set (0.00 sec)
//
//mysql> select * from stu;
//+----+--------+----------+
//        | id | name   | class_id |
//        +----+--------+----------+
//        |  1 | 张三   |        1 |
//        |  2 | 李四   |        2 |
//        |  3 | 王五   |        3 |
//        +----+--------+----------+
//        3 rows in set (0.00 sec)
//
//mysql> desc stu;
//+----------+-------------+------+-----+---------+----------------+
//        | Field    | Type        | Null | Key | Default | Extra          |
//        +----------+-------------+------+-----+---------+----------------+
//        | id       | int         | NO   | PRI | NULL    | auto_increment |
//        | name     | varchar(20) | NO   |     | NULL    |                |
//        | class_id | int         | YES  | MUL | NULL    |                |
//        +----------+-------------+------+-----+---------+----------------+
//        3 rows in set (0.00 sec)
//
//mysql> desc stu2;
//+--------+-------------+------+-----+---------+----------------+
//        | Field  | Type        | Null | Key | Default | Extra          |
//        +--------+-------------+------+-----+---------+----------------+
//        | id     | int         | NO   | PRI | NULL    | auto_increment |
//        | name   | varchar(20) | NO   |     | NULL    |                |
//        | gender | varchar(1)  | NO   |     | NULL    |                |
//        +--------+-------------+------+-----+---------+----------------+
//        3 rows in set (0.00 sec)
//
//mysql> drop table if exists stu2
//    -> ;
//Query OK, 0 rows affected (0.02 sec)
//
//mysql> create table if not exists stu1 9
//        -> ^Z^C
//mysql> create table if not exists stu1 (
//    -> id int primary key auto_increment,
//    -> name varchar(20) not null
//        -> );
//Query OK, 0 rows affected (0.02 sec)
//
//mysql> insert into stu1 (id, name) select (id, name) from stu;
//ERROR 1241 (21000): Operand should contain 1 column(s)
//mysql> insert into stu1 (id, name) select id, name from stu;
//Query OK, 3 rows affected (0.01 sec)
//Records: 3  Duplicates: 0  Warnings: 0
//
//mysql> select * from stu1;
//+----+--------+
//        | id | name   |
//        +----+--------+
//        |  1 | 张三   |
//        |  2 | 李四   |
//        |  3 | 王五   |
//        +----+--------+
//        3 rows in set (0.00 sec)
//
//mysql> insert into stu1 (name) select id, name from stu;
//ERROR 1136 (21S01): Column count doesn't match value count at row 1
//mysql> select * from score;
//+----+-----------+---------+------+---------+
//        | id | name      | chinese | math | english |
//        +----+-----------+---------+------+---------+
//        |  3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |  4 | 曹孟德    |    70.0 | 30.0 |    67.0 |
//        |  6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |  8 | 孙行者    |    87.5 | 78.0 |    77.0 |
//        +----+-----------+---------+------+---------+
//        4 rows in set (0.00 sec)
//
//mysql> drop table if exists score;
//Query OK, 0 rows affected (0.01 sec)
//
//mysql> -- 创建考试成绩表
//mysql> DROP TABLE IF EXISTS exam;
//Query OK, 0 rows affected, 1 warning (0.00 sec)
//
//mysql> CREATE TABLE exam (
//    ->     id bigint,
//    ->     name VARCHAR(20),
//    ->     chinese DECIMAL(3,1),
//    ->     math DECIMAL(3,1),
//    ->     english DECIMAL(3,1)
//    -> );
//Query OK, 0 rows affected (0.01 sec)
//
//mysql> -- 插入测试数据
//mysql> INSERT INTO exam (id,name, chinese, math, english) VALUES
//    -> (1,'唐三藏', 67, 98, 56),
//            -> (2,'孙悟空', 87.5, 78, 77),
//            -> (3,'猪悟能', 88, 98, 90),
//            -> (4,'曹孟德', 82, 84, 67),
//            -> (5,'刘玄德', 55.5, 85, 45),
//            -> (6,'孙权', 70, 73, 78.5),
//            -> (7,'宋公明', 75, 65, 30);
//Query OK, 7 rows affected (0.01 sec)
//Records: 7  Duplicates: 0  Warnings: 0
//
//mysql> select * from exam;
//+------+-----------+---------+------+---------+
//        | id   | name      | chinese | math | english |
//        +------+-----------+---------+------+---------+
//        |    1 | 唐三藏    |    67.0 | 98.0 |    56.0 |
//        |    2 | 孙悟空    |    87.5 | 78.0 |    77.0 |
//        |    3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |    4 | 曹孟德    |    82.0 | 84.0 |    67.0 |
//        |    5 | 刘玄德    |    55.5 | 85.0 |    45.0 |
//        |    6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |    7 | 宋公明    |    75.0 | 65.0 |    30.0 |
//        +------+-----------+---------+------+---------+
//        7 rows in set (0.00 sec)
//
//mysql> select count(*) from exam;
//+----------+
//        | count(*) |
//        +----------+
//        |        7 |
//        +----------+
//        1 row in set (0.00 sec)
//
//mysql> insert into exam (name, chinese, math, english) values ('孙行者', 87.5, 78, 77), ('赵云', 40, 80, 90), ('黄忠', 60, 70, 50);
//Query OK, 3 rows affected (0.01 sec)
//Records: 3  Duplicates: 0  Warnings: 0
//
//mysql> select * from exam;
//+------+-----------+---------+------+---------+
//        | id   | name      | chinese | math | english |
//        +------+-----------+---------+------+---------+
//        |    1 | 唐三藏    |    67.0 | 98.0 |    56.0 |
//        |    2 | 孙悟空    |    87.5 | 78.0 |    77.0 |
//        |    3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |    4 | 曹孟德    |    82.0 | 84.0 |    67.0 |
//        |    5 | 刘玄德    |    55.5 | 85.0 |    45.0 |
//        |    6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |    7 | 宋公明    |    75.0 | 65.0 |    30.0 |
//        | NULL | 孙行者    |    87.5 | 78.0 |    77.0 |
//        | NULL | 赵云      |    40.0 | 80.0 |    90.0 |
//        | NULL | 黄忠      |    60.0 | 70.0 |    50.0 |
//        +------+-----------+---------+------+---------+
//        10 rows in set (0.00 sec)
//
//mysql> desc exam;
//+---------+--------------+------+-----+---------+-------+
//        | Field   | Type         | Null | Key | Default | Extra |
//        +---------+--------------+------+-----+---------+-------+
//        | id      | bigint       | YES  |     | NULL    |       |
//        | name    | varchar(20)  | YES  |     | NULL    |       |
//        | chinese | decimal(3,1) | YES  |     | NULL    |       |
//        | math    | decimal(3,1) | YES  |     | NULL    |       |
//        | english | decimal(3,1) | YES  |     | NULL    |       |
//        +---------+--------------+------+-----+---------+-------+
//        5 rows in set (0.00 sec)
//
//mysql> drop table if exists exam;
//Query OK, 0 rows affected (0.01 sec)
//
//mysql> CREATE TABLE exam (
//    ->     id bigint,
//    ->     name VARCHAR(20),
//    ->     chinese DECIMAL(3,1),
//    ->     math DECIMAL(3,1),
//    ->     english DECIMAL(3,1)
//    -> CREATE TABLE exam (^C
//        mysql> create table if not exists exam (
//    -> id int primary key auto_inmrement,
//    -> name varchar(20) not null,
//        -> chinese decimal(3,1) not null,
//        -> math decimal(3, 1) not null,
//        -> engliah decimal(3,1) not null
//        -> );
//ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'auto_inmrement,
//name varchar(20) not null,
//chinese decimal(3,1) not null,
//math d' at line 2
//mysql> create table if not exists exam (
//    -> id int primary key auto_increment,
//    -> name varchar(20) not null,
//        -> chinese decimal(3,1) not null,
//        -> math decimal(3, 1) not null,
//        -> engliah decimal(3,1) not null
//        -> );
//Query OK, 0 rows affected (0.02 sec)
//
//mysql> desc exam;
//+---------+--------------+------+-----+---------+----------------+
//        | Field   | Type         | Null | Key | Default | Extra          |
//        +---------+--------------+------+-----+---------+----------------+
//        | id      | int          | NO   | PRI | NULL    | auto_increment |
//        | name    | varchar(20)  | NO   |     | NULL    |                |
//        | chinese | decimal(3,1) | NO   |     | NULL    |                |
//        | math    | decimal(3,1) | NO   |     | NULL    |                |
//        | engliah | decimal(3,1) | NO   |     | NULL    |                |
//        +---------+--------------+------+-----+---------+----------------+
//        5 rows in set (0.00 sec)
//
//mysql> INSERT INTO exam (id,name, chinese, math, english) VALUES
//    -> (1,'唐三藏', 67, 98, 56),
//            -> (2,'孙悟空', 87.5, 78, 77),
//            -> (3,'猪悟能', 88, 98, 90),
//            -> (4,'曹孟德', 82, 84, 67),
//            -> (5,'刘玄德', 55.5, 85, 45),
//            -> (6,'孙权', 70, 73, 78.5),
//            -> (7,'宋公明', 75, 65, 30);
//ERROR 1054 (42S22): Unknown column 'english' in 'field list'
//mysql> drop table if exists exam;
//Query OK, 0 rows affected (0.01 sec)
//
//mysql> INSERT INTO exam (id,name, chinese, math, english) VALUES
//    -> (1,'唐三藏', 67, 98, 56),
//            -> (2,'孙悟空', 87.5, 78, 77),
//            -> (3,'猪悟能', 88, 98, 90),
//            -> (4,'曹孟德', 82, 84, 67),
//            -> (5,'刘玄德', 55.5, 85, 45),
//            -> (6,'孙权', 70, 73, 78.5),
//            -> (7,'宋公明', 75, 65, 30);
//Query OK, 7 rows affected (0.01 sec)
//Records: 7  Duplicates: 0  Warnings: 0
//
//mysql> select * from exam;
//+----+-----------+---------+------+---------+
//        | id | name      | chinese | math | english |
//        +----+-----------+---------+------+---------+
//        |  1 | 唐三藏    |    67.0 | 98.0 |    56.0 |
//        |  2 | 孙悟空    |    87.5 | 78.0 |    77.0 |
//        |  3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |  4 | 曹孟德    |    82.0 | 84.0 |    67.0 |
//        |  5 | 刘玄德    |    55.5 | 85.0 |    45.0 |
//        |  6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |  7 | 宋公明    |    75.0 | 65.0 |    30.0 |
//        +----+-----------+---------+------+---------+
//        7 rows in set (0.00 sec)
//
//mysql> insert into exam (name, chinese, math, english) values ('孙行者', 87.5, 78, 77), ('赵云', 40, 80, 90), ('黄忠', 60, 70, 50);
//Query OK, 3 rows affected (0.01 sec)
//Records: 3  Duplicates: 0  Warnings: 0
//
//mysql> select * from exam;
//+----+-----------+---------+------+---------+
//        | id | name      | chinese | math | english |
//        +----+-----------+---------+------+---------+
//        |  1 | 唐三藏    |    67.0 | 98.0 |    56.0 |
//        |  2 | 孙悟空    |    87.5 | 78.0 |    77.0 |
//        |  3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |  4 | 曹孟德    |    82.0 | 84.0 |    67.0 |
//        |  5 | 刘玄德    |    55.5 | 85.0 |    45.0 |
//        |  6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |  7 | 宋公明    |    75.0 | 65.0 |    30.0 |
//        |  8 | 孙行者    |    87.5 | 78.0 |    77.0 |
//        |  9 | 赵云      |    40.0 | 80.0 |    90.0 |
//        | 10 | 黄忠      |    60.0 | 70.0 |    50.0 |
//        +----+-----------+---------+------+---------+
//        10 rows in set (0.00 sec)
//
//mysql> select count(*) from exam;
//+----------+
//        | count(*) |
//        +----------+
//        |       10 |
//        +----------+
//        1 row in set (0.00 sec)
//
//mysql> show tables;
//+----------------+
//        | Tables_in_test |
//        +----------------+
//        | class          |
//        | exam           |
//        | stu            |
//        | stu1           |
//        +----------------+
//        4 rows in set (0.00 sec)
//
//mysql> select * from class;
//+----+---------+
//        | id | name    |
//        +----+---------+
//        |  1 | java113 |
//        |  2 | java112 |
//        |  3 | java111 |
//        |  4 | java110 |
//        +----+---------+
//        4 rows in set (0.01 sec)
//
//mysql> select * from stu;
//+----+--------+----------+
//        | id | name   | class_id |
//        +----+--------+----------+
//        |  1 | 张三   |        1 |
//        |  2 | 李四   |        2 |
//        |  3 | 王五   |        3 |
//        +----+--------+----------+
//        3 rows in set (0.00 sec)
//
//mysql> select count(id) from exam;
//+-----------+
//        | count(id) |
//        +-----------+
//        |        10 |
//        +-----------+
//        1 row in set (0.00 sec)
//
//mysql> select id, name, sum(chinese + math + english) from exam;
//ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'test.exam.id'; this is incompatible with sql_mode=only_full_group_by
//mysql> select sum(chinese) + sum(math) + sum(english) from exam;
//+-----------------------------------------+
//        | sum(chinese) + sum(math) + sum(english) |
//        +-----------------------------------------+
//        |                                  2182.0 |
//        +-----------------------------------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(chinese + math + english) from exam;
//+-------------------------------+
//        | sum(chinese + math + english) |
//        +-------------------------------+
//        |                        2182.0 |
//        +-------------------------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(english) from exam order by english asc limit 3;
//        +--------------+
//        | sum(english) |
//        +--------------+
//        |        660.5 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(english) from exam where english < 60;
//        +--------------+
//        | sum(english) |
//        +--------------+
//        |        181.0 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(english) from exam;
//+--------------+
//        | sum(english) |
//        +--------------+
//        |        660.5 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(english) from exam order by english limit 3;
//        +--------------+
//        | sum(english) |
//        +--------------+
//        |        660.5 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(english) from exam where (select english frm exam where order by english asc limit 3);
//ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'exam where order by english asc limit 3)' at line 1
//mysql> select sum(english) from exam where (select english from exam where order by english asc limit 3);
//ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by english asc limit 3)' at line 1
//mysql> select sum(english) from exam where (select english from exam order by english asc limit 3);
//ERROR 1242 (21000): Subquery returns more than 1 row
//mysql> select sum(english) from (select english from exam order by english asc limit 3);
//ERROR 1248 (42000): Every derived table must have its own alias
//mysql> select sum(english) from (select english from exam order by english asc limit 3) as exam2;
//+--------------+
//        | sum(english) |
//        +--------------+
//        |        125.0 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(name) from exam;
//+-----------+
//        | sum(name) |
//        +-----------+
//        |         0 |
//        +-----------+
//        1 row in set, 10 warnings (0.00 sec)
//
//mysql> show warnings;
//+---------+------+-----------------------------------------------+
//        | Level   | Code | Message                                       |
//        +---------+------+-----------------------------------------------+
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '唐三藏'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '孙悟空'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '猪悟能'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '曹孟德'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '刘玄德'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '孙权'      |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '宋公明'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '孙行者'    |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '赵云'      |
//        | Warning | 1292 | Truncated incorrect DOUBLE value: '黄忠'      |
//        +---------+------+-----------------------------------------------+
//        10 rows in set (0.00 sec)
//
//mysql> select avg(chinese) from exam;
//+--------------+
//        | avg(chinese) |
//        +--------------+
//        |     71.25000 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select avg(chinese) from (select chinese from exam order by chinese asc limit 3) as exam2;
//+--------------+
//        | avg(chinese) |
//        +--------------+
//        |     51.83333 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select avg(chinese) from exam where chinese < 60;
//        +--------------+
//        | avg(chinese) |
//        +--------------+
//        |     47.75000 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select avg(chinese + math + english) from exam;
//+-------------------------------+
//        | avg(chinese + math + english) |
//        +-------------------------------+
//        |                     218.20000 |
//        +-------------------------------+
//        1 row in set (0.00 sec)
//
//mysql> select avg(chinese + math + english) as '总分平均值' from exam;
//+-----------------+
//        | 总分平均值      |
//        +-----------------+
//        |       218.20000 |
//        +-----------------+
//        1 row in set (0.00 sec)
//
//mysql> select max(chinese + math + english) from exam;
//+-------------------------------+
//        | max(chinese + math + english) |
//        +-------------------------------+
//        |                         276.0 |
//        +-------------------------------+
//        1 row in set (0.00 sec)
//
//mysql> select min(chinese + math + english) from exam;
//+-------------------------------+
//        | min(chinese + math + english) |
//        +-------------------------------+
//        |                         170.0 |
//        +-------------------------------+
//        1 row in set (0.00 sec)
//
//mysql> select max(chinese + math + english) from (select chinese + math + english as '总分' from exam order by '总分' desc limit 3) as exam2;
//ERROR 1054 (42S22): Unknown column 'chinese' in 'field list'
//mysql>  select max(chinese + math + english) from (select chinese + math + english as '总分' from exam order by '总分' desc limit 3) as exam2;
//ERROR 1054 (42S22): Unknown column 'chinese' in 'field list'

//mysql> select max(chinese + math + english) from (select chinese + math + english as '总分' from exam order by '总分' desc limit 3) as exam2;
//ERROR 1054 (42S22): Unknown column 'chinese' in 'field list'
//mysql>  select max(chinese + math + english) from (select chinese + math + english as '总分' from exam order by '总分' desc limit 3) as exam2;
//ERROR 1054 (42S22): Unknown column 'chinese' in 'field list'
//mysql> select * from exam;
//+----+-----------+---------+------+---------+
//        | id | name      | chinese | math | english |
//        +----+-----------+---------+------+---------+
//        |  1 | 唐三藏    |    67.0 | 98.0 |    56.0 |
//        |  2 | 孙悟空    |    87.5 | 78.0 |    77.0 |
//        |  3 | 猪悟能    |    88.0 | 98.0 |    90.0 |
//        |  4 | 曹孟德    |    82.0 | 84.0 |    67.0 |
//        |  5 | 刘玄德    |    55.5 | 85.0 |    45.0 |
//        |  6 | 孙权      |    70.0 | 73.0 |    78.5 |
//        |  7 | 宋公明    |    75.0 | 65.0 |    30.0 |
//        |  8 | 孙行者    |    87.5 | 78.0 |    77.0 |
//        |  9 | 赵云      |    40.0 | 80.0 |    90.0 |
//        | 10 | 黄忠      |    60.0 | 70.0 |    50.0 |
//        +----+-----------+---------+------+---------+
//        10 rows in set (0.00 sec)
//
//mysql> select sum(english) from exam order by english asc limit 3;
//        +--------------+
//        | sum(english) |
//        +--------------+
//        |        660.5 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> select sum(english) from
//    -> (select english from exam order by english asc limit 3) as exam2;
//+--------------+
//        | sum(english) |
//        +--------------+
//        |        125.0 |
//        +--------------+
//        1 row in set (0.00 sec)
//
//mysql> show rables;
//ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rables' at line 1
//mysql> show tables;
//+----------------+
//        | Tables_in_test |
//        +----------------+
//        | class          |
//        | exam           |
//        | stu            |
//        | stu1           |
//        +----------------+
//        4 rows in set (0.00 sec)
//
//mysql> use java113;
//Database changed
//mysql> show tables;
//+-------------------+
//        | Tables_in_java113 |
//        +-------------------+
//        | class             |
//        | course            |
//        | emp               |
//        | score             |
//        | stu2              |
//        | student           |
//        +-------------------+
//        6 rows in set (0.00 sec)
//
//mysql> select * from emp;
//+----+-----------+--------------+------------+
//        | id | name      | role         | salary     |
//        +----+-----------+--------------+------------+
//        |  1 | 马云      | 老板         | 1500000.00 |
//        |  2 | 马化腾    | 老板         | 1800000.00 |
//        |  3 | 鑫哥      | 讲师         |   10000.00 |
//        |  4 | 博哥      | 讲师         |   12000.00 |
//        |  5 | 平姐      | 学管         |    9000.00 |
//        |  6 | 莹姐      | 学管         |    8000.00 |
//        |  7 | 猪悟能    | 游戏角色     |     700.50 |
//        |  8 | 沙和尚    | 游戏角色     |     333.30 |
//        +----+-----------+--------------+------------+
//        8 rows in set (0.01 sec)
//
//mysql> select role, avg(salary) from emp group by role;
//+--------------+----------------+
//        | role         | avg(salary)    |
//        +--------------+----------------+
//        | 老板         | 1650000.000000 |
//        | 讲师         |   11000.000000 |
//        | 学管         |    8500.000000 |
//        | 游戏角色     |     516.900000 |
//        +--------------+----------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role;
//+--------------+-----------------------+
//        | role         | round(avg(salary), 2) |
//        +--------------+-----------------------+
//        | 老板         |            1650000.00 |
//        | 讲师         |              11000.00 |
//        | 学管         |               8500.00 |
//        | 游戏角色     |                516.90 |
//        +--------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role order by avg(salary) asc;
//+--------------+-----------------------+
//        | role         | round(avg(salary), 2) |
//        +--------------+-----------------------+
//        | 游戏角色     |                516.90 |
//        | 学管         |               8500.00 |
//        | 讲师         |              11000.00 |
//        | 老板         |            1650000.00 |
//        +--------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role order by round(avg(salary), 2);
//        +--------------+-----------------------+
//        | role         | round(avg(salary), 2) |
//        +--------------+-----------------------+
//        | 游戏角色     |                516.90 |
//        | 学管         |               8500.00 |
//        | 讲师         |              11000.00 |
//        | 老板         |            1650000.00 |
//        +--------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) as '平均工资' from emp group by role order by '平均工资' asc;
//+--------------+--------------+
//        | role         | 平均工资     |
//        +--------------+--------------+
//        | 老板         |   1650000.00 |
//        | 讲师         |     11000.00 |
//        | 学管         |      8500.00 |
//        | 游戏角色     |       516.90 |
//        +--------------+--------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) as '平均工资' from emp group by role order by '平均工资' desc;
//+--------------+--------------+
//        | role         | 平均工资     |
//        +--------------+--------------+
//        | 老板         |   1650000.00 |
//        | 讲师         |     11000.00 |
//        | 学管         |      8500.00 |
//        | 游戏角色     |       516.90 |
//        +--------------+--------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) as '平均工资' from emp group by role order by '平均工资' asc;
//+--------------+--------------+
//        | role         | 平均工资     |
//        +--------------+--------------+
//        | 老板         |   1650000.00 |
//        | 讲师         |     11000.00 |
//        | 学管         |      8500.00 |
//        | 游戏角色     |       516.90 |
//        +--------------+--------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role order by round(avg(salary), 2) asc;
//+--------------+-----------------------+
//        | role         | round(avg(salary), 2) |
//        +--------------+-----------------------+
//        | 游戏角色     |                516.90 |
//        | 学管         |               8500.00 |
//        | 讲师         |              11000.00 |
//        | 老板         |            1650000.00 |
//        +--------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role where round(avg(salary), 2) between 10000 and 200000;
//ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where round(avg(salary), 2) between 10000 and 200000' at line 1
//mysql> select role, round(avg(salary), 2) from emp group by role having round(avg(salary), 2) between 10000 and 200000;
//        +--------+-----------------------+
//        | role   | round(avg(salary), 2) |
//        +--------+-----------------------+
//        | 讲师   |              11000.00 |
//        +--------+-----------------------+
//        1 row in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp where salary > 1000 group by role order by round(avg(salary), 2) asc;
//
//+--------+-----------------------+
//        | role   | round(avg(salary), 2) |
//        +--------+-----------------------+
//        | 学管   |               8500.00 |
//        | 讲师   |              11000.00 |
//        | 老板   |            1650000.00 |
//        +--------+-----------------------+
//        3 rows in set (0.00 sec)
//
//mysql> select max(salary), min(salary), round(avg(salary), 2) from emp group by role;
//+-------------+-------------+-----------------------+
//        | max(salary) | min(salary) | round(avg(salary), 2) |
//        +-------------+-------------+-----------------------+
//        |  1800000.00 |  1500000.00 |            1650000.00 |
//        |    12000.00 |    10000.00 |              11000.00 |
//        |     9000.00 |     8000.00 |               8500.00 |
//        |      700.50 |      333.30 |                516.90 |
//        +-------------+-------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role,max(salary), min(salary), round(avg(salary), 2) from emp group by role;
//+--------------+-------------+-------------+-----------------------+
//        | role         | max(salary) | min(salary) | round(avg(salary), 2) |
//        +--------------+-------------+-------------+-----------------------+
//        | 老板         |  1800000.00 |  1500000.00 |            1650000.00 |
//        | 讲师         |    12000.00 |    10000.00 |              11000.00 |
//        | 学管         |     9000.00 |     8000.00 |               8500.00 |
//        | 游戏角色     |      700.50 |      333.30 |                516.90 |
//        +--------------+-------------+-------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp where round(avg(salary), 2) < 1500 group by role;
//ERROR 1111 (HY000): Invalid use of group function
//mysql> show warnings;
//+-------+------+-------------------------------+
//        | Level | Code | Message                       |
//        +-------+------+-------------------------------+
//        | Error | 1111 | Invalid use of group function |
//        +-------+------+-------------------------------+
//        1 row in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role having round(avg(salary), 2);
//        +--------------+-----------------------+
//        | role         | round(avg(salary), 2) |
//        +--------------+-----------------------+
//        | 老板         |            1650000.00 |
//        | 讲师         |              11000.00 |
//        | 学管         |               8500.00 |
//        | 游戏角色     |                516.90 |
//        +--------------+-----------------------+
//        4 rows in set (0.00 sec)
//
//mysql> select role, round(avg(salary), 2) from emp group by role having round(avg(salary), 2) < 1500;
//        +--------------+-----------------------+
//        | role         | round(avg(salary), 2) |
//        +--------------+-----------------------+
//        | 游戏角色     |                516.90 |
//        +--------------+-----------------------+
//        1 row in set (0.00 sec)
//
//mysql>